from langgraph.graph import StateGraph, START, END
from pydantic import BaseModel


class LoopState(BaseModel):
    x: int


def increment(state: LoopState) -> LoopState:
    return LoopState(x=state.x + 1)


def is_done(state: LoopState) -> bool:
    return state.x >= 10


builder = StateGraph(LoopState)
builder.add_node(increment, "increment")
builder.add_conditional_edges("increment", is_done, {
    True: END,
    False: "increment",
})
builder.add_edge(START, "increment")
graph = builder.compile()
